package com.victor.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.victor.entity.Copyright;

@Mapper
public interface CopyrightDao {// extends JpaRepository<Copyright, Integer> {


	/**
	 * 获取所有版权方列表
	 * 
	 * @return
	 */
	@Select({ "select * from copyright order by id desc" })
	List<Copyright> getAllCopyright();

	/**
	 * 通过新建的账号去数据库查询是否重复
	 * 
	 * @param cr_account
	 * @return
	 */
	@Select({ "select * from copyright where cr_account=#{cr_account}" })
	Copyright loginexistCopyright(@Param("cr_account") String cr_account);

	/**
	 * 插入数据库版权方
	 * 
	 * @param copyright
	 * @return
	 */
	@Insert({ "insert into copyright (identifier,copyrightname,cr_account,cr_password,remarks,createtime) values (#{identifier},#{copyrightname},#{cr_account},#{cr_password},#{remarks},NOW())" })
	int createCopyright(Copyright copyright);

	/**
	 * 修改信息
	 * 
	 * @param copyright
	 * @return
	 */
	int updateCopyright(Copyright copyright);

	/**
	 * 批量删除版权方
	 * 
	 * @param ids
	 * @return
	 */
	int batchDeleteCopyright(@Param("ids") int[] ids);

	/**
	 * 版权方登录判断
	 * 
	 * @param copyright
	 * @return
	 */
	@Select({ "select * from copyright where cr_account=#{cr_account} and cr_password=#{cr_password}" })
	Copyright loginCopyright(Copyright copyright);

	@Select({ "select * from copyright where copyrightname like concat('%',#{name},'%') "})
	List<Copyright> search(@Param("name")String name);

}
